<ng-template #modal let-hide="close">
  <div class="modal-header">
    <h4 i18n class="modal-title">Share</h4>
    <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon>
  </div>


  <div class="modal-body">

    <div class="playlist" *ngIf="playlist">
      <div class="title-page title-page-single" i18n *ngIf="video">Share the playlist</div>

      <div ngbNav #nav="ngbNav" class="nav-tabs" [(activeId)]="activePlaylistId">

        <ng-container ngbNavItem="url">
          <a ngbNavLink i18n>URL</a>

          <ng-template ngbNavContent>
            <div class="nav-content">

              <my-input-toggle-hidden [value]="getPlaylistUrl()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
            </div>
          </ng-template>
        </ng-container>

        <ng-container ngbNavItem="qrcode">
          <a ngbNavLink i18n>QR-Code</a>

          <ng-template ngbNavContent>
            <div class="nav-content">
              <qrcode [qrdata]="getPlaylistUrl()" [size]="256" level="Q"></qrcode>
            </div>
          </ng-template>
        </ng-container>

        <ng-container ngbNavItem="embed">
          <a ngbNavLink i18n>Embed</a>

          <ng-template ngbNavContent>
            <div class="nav-content">
              <my-input-toggle-hidden [value]="getPlaylistIframeCode()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>

              <div i18n *ngIf="notSecure()" class="alert alert-warning">
                The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites).
              </div>
            </div>
          </ng-template>
        </ng-container>

      </div>

      <div [ngbNavOutlet]="nav"></div>

      <div class="filters">

        <div class="form-group" *ngIf="video">
          <my-peertube-checkbox inputName="includeVideoInPlaylist" [(ngModel)]="includeVideoInPlaylist" i18n-labelText
            labelText="Share the playlist at this video position"></my-peertube-checkbox>
        </div>

      </div>
    </div>


    <div class="video" *ngIf="video">
      <div class="title-page title-page-single" *ngIf="playlist" i18n>Share the video</div>

      <div ngbNav #nav="ngbNav" class="nav-tabs" [(activeId)]="activeVideoId">

        <ng-container ngbNavItem="url">
          <a ngbNavLink i18n>URL</a>

          <ng-template ngbNavContent>
            <div class="nav-content">
              <my-input-toggle-hidden [value]="getVideoUrl()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
            </div>
          </ng-template>
        </ng-container>

        <ng-container ngbNavItem="qrcode">
          <a ngbNavLink i18n>QR-Code</a>

          <ng-template ngbNavContent>
            <div class="nav-content">
              <qrcode [qrdata]="getVideoUrl()" [size]="256" level="Q"></qrcode>
            </div>
          </ng-template>
        </ng-container>

        <ng-container ngbNavItem="embed">
          <a ngbNavLink i18n>Embed</a>

          <ng-template ngbNavContent>
            <div class="nav-content">
              <my-input-toggle-hidden [value]="getVideoIframeCode()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>

              <div i18n *ngIf="notSecure()" class="alert alert-warning">
                The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites).
              </div>
            </div>
          </ng-template>
        </ng-container>

      </div>

      <div [ngbNavOutlet]="nav"></div>

      <div class="filters">
        <div>
          <div class="form-group start-at" *ngIf="!video.isLive">
            <my-peertube-checkbox
              inputName="startAt" [(ngModel)]="customizations.startAtCheckbox"
              i18n-labelText labelText="Start at"
            ></my-peertube-checkbox>

            <my-timestamp-input
              [timestamp]="customizations.startAt"
              [maxTimestamp]="video.duration"
              [disabled]="!customizations.startAtCheckbox"
              [(ngModel)]="customizations.startAt"
            >
            </my-timestamp-input>
          </div>

          <div *ngIf="videoCaptions.length !== 0" class="form-group video-caption-block">
            <my-peertube-checkbox
              inputName="subtitleCheckbox" [(ngModel)]="customizations.subtitleCheckbox"
              i18n-labelText labelText="Auto select subtitle"
            ></my-peertube-checkbox>

            <div class="peertube-select-container" [ngClass]="{ disabled: !customizations.subtitleCheckbox }">
              <select [(ngModel)]="customizations.subtitle" [disabled]="!customizations.subtitleCheckbox">
                <option *ngFor="let caption of videoCaptions" [value]="caption.language.id">{{ caption.language.label }}</option>
              </select>
            </div>
          </div>
        </div>

        <div class="advanced-filters collapse-transition" [ngbCollapse]="isAdvancedCustomizationCollapsed">
          <div>
            <div class="form-group stop-at" *ngIf="!video.isLive">
              <my-peertube-checkbox
                inputName="stopAt" [(ngModel)]="customizations.stopAtCheckbox"
                i18n-labelText labelText="Stop at"
              ></my-peertube-checkbox>

              <my-timestamp-input
                [timestamp]="customizations.stopAt"
                [maxTimestamp]="video.duration"
                [disabled]="!customizations.stopAtCheckbox"
                [(ngModel)]="customizations.stopAt"
              >
              </my-timestamp-input>
            </div>

            <div class="form-group">
              <my-peertube-checkbox
                inputName="autoplay" [(ngModel)]="customizations.autoplay"
                i18n-labelText labelText="Autoplay"
              ></my-peertube-checkbox>
            </div>

            <div class="form-group">
              <my-peertube-checkbox
                inputName="muted" [(ngModel)]="customizations.muted"
                i18n-labelText labelText="Muted"
              ></my-peertube-checkbox>
            </div>

            <div class="form-group" *ngIf="!video.isLive">
              <my-peertube-checkbox
                inputName="loop" [(ngModel)]="customizations.loop"
                i18n-labelText labelText="Loop"
              ></my-peertube-checkbox>
            </div>

            <div *ngIf="!isLocalVideo() && !isVideoInEmbedTab()" class="form-group">
              <my-peertube-checkbox
                inputName="originUrl" [(ngModel)]="customizations.originUrl"
                i18n-labelText labelText="Use origin instance URL"
              ></my-peertube-checkbox>
            </div>
          </div>

          <ng-container *ngIf="isVideoInEmbedTab()">
            <div class="form-group">
              <my-peertube-checkbox
                inputName="title" [(ngModel)]="customizations.title"
                i18n-labelText labelText="Display video title"
              ></my-peertube-checkbox>
            </div>

            <div class="form-group">
              <my-peertube-checkbox
                inputName="warningTitle" [(ngModel)]="customizations.warningTitle"
                i18n-labelText labelText="Display privacy warning"
              ></my-peertube-checkbox>
            </div>

            <div class="form-group">
              <my-peertube-checkbox
                inputName="controls" [(ngModel)]="customizations.controls"
                i18n-labelText labelText="Display player controls"
              ></my-peertube-checkbox>
            </div>

            <div class="form-group">
              <my-peertube-checkbox
                inputName="controls" [(ngModel)]="customizations.peertubeLink"
                i18n-labelText labelText="Display PeerTube button link"
              ></my-peertube-checkbox>
            </div>
          </ng-container>
        </div>

        <div (click)="isAdvancedCustomizationCollapsed = !isAdvancedCustomizationCollapsed" role="button" class="advanced-filters-button"
             [attr.aria-expanded]="!isAdvancedCustomizationCollapsed" aria-controls="collapseBasic">

          <ng-container *ngIf="isAdvancedCustomizationCollapsed">
            <span class="glyphicon glyphicon-menu-down"></span>

            <ng-container i18n>
              More customization
            </ng-container>
          </ng-container>

          <ng-container *ngIf="!isAdvancedCustomizationCollapsed">
            <span class="glyphicon glyphicon-menu-up"></span>

            <ng-container i18n>
              Less customization
            </ng-container>
          </ng-container>
        </div>
      </div>
    </div>
  </div>

</ng-template>
